package org.springblade.oa.wrappper;

import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.oa.entity.Bxsh;
import org.springblade.oa.service.IBxshService;
import org.springblade.oa.service.IExpenseAccountService;
import org.springblade.oa.vo.BxshVO;
import org.springblade.system.feign.IDictClient;
import org.springblade.system.user.entity.UserInfo;
import org.springblade.system.user.feign.IUserClient;

/**
 * @author LK
 * @version 1.0.0
 * @Title: BxshWrapper.java
 * @Description: TODO    返回视图层所需要报销审核
 * @date 2020/1/17 13:48
 */
public class BxshWrapper extends BaseEntityWrapper<Bxsh, BxshVO> {

	private static IBxshService bxshService;

	private static IDictClient dictClient;

	private static IUserClient userClient;

	private static IExpenseAccountService expenseAccountService;

	static {
		bxshService = SpringUtil.getBean(IBxshService.class);
		dictClient = SpringUtil.getBean(IDictClient.class);
		userClient = SpringUtil.getBean(IUserClient.class);
		expenseAccountService=SpringUtil.getBean(IExpenseAccountService.class);
	}

	public static BxshWrapper build() {
		return new BxshWrapper();
	}

	@Override
	public BxshVO entityVO(Bxsh bxsh) {
		BxshVO bxshVO = BeanUtil.copy(bxsh, BxshVO.class);
		R<String> shztName = dictClient.getValue("bx_cz", bxsh.getShzt());
		if (shztName.isSuccess()) {
			bxshVO.setShztName(shztName.getData());
		}
		/*R<UserInfo> userInfo = userClient.userInfo(bxsh.getCreateUser().longValue());
		if (userInfo.isSuccess()) {
			bxshVO.setCreateUserName(userInfo.getData().getUser().getRealName());
		}*/
		String userName = expenseAccountService.getUserById(bxsh.getCreateUser());
		bxshVO.setCreateUserName(userName);
		return bxshVO;
	}
}
